package com.szhn.aclservice.controller;


import com.szhn.aclservice.entity.vo.AssignRoleVo;
import com.szhn.aclservice.service.AclUserRoleService;
import com.szhn.common.responsejson.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-10-28
 */
@RestController
@RequestMapping("/aclservice/acl-user-role")
public class AclUserRoleController {

    @Autowired
    private AclUserRoleService aclUserRoleService;

    @ApiOperation("根据用户获取改用户拥有的角色和所有角色")
    @GetMapping("toAssign/{userId}")
    public R toAssign (@PathVariable String userId){
        Map<String,Object> roleMap = aclUserRoleService.getRolesByUserId(userId);
        return R.ok();
    }

    @ApiOperation("给用户分配角色")
    @PostMapping("doAssign")
    public R doAssign(@RequestBody AssignRoleVo assignRoleVo){
        aclUserRoleService.doAssign(assignRoleVo);
        return R.ok();

    }

}

